
package com.loukou.lkt.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.loukou.lkt.lkt.resp.AuthInfo;

/**
 * 在Controller类上加@AuthCheck注解则将整个Controller纳入身份验证
 * 在方法上加@AuthCheck注解则将该方法纳入身份验证
 * 注解@AuthCheck(privileges = {"lkt.pushToWms","lkt.manageLktData"}, isRedirect = true)表示需要"lkt.pushToWms","lkt.manageLktData"这两个权限，
 * 如果权限不足则直接跳转到权限不足提示页面，如果设置isRedirect = false则返回给前台一个json数组提示权限不足
 * 加上@AuthCheck注解会验证当前session中是否有登陆信息，若没有登陆过则返回登陆页面或json提示没有登陆，
 * TestController中有些实例可以参考
 * @author sunchuanlei
 *
 */
@Controller
@RequestMapping("/")
public class HomeController extends BaseController {
	@Autowired
	private HttpServletRequest request;
	
	@RequestMapping("")
	public String home(){
		HttpSession session = request.getSession();
		if(session != null){
			AuthInfo authInfo = (AuthInfo)session.getAttribute("authInfo");
			if(authInfo != null){
				return "main";
			}
		}
		return "login";
	}
	
	@RequestMapping("index")
	public String index(){
		return "index";
	}
	
}

